import { ApiProperty } from '@nestjs/swagger';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { Hotel } from './hotel.entity';
import { Order } from './order.entity';

@Entity()
export class Room {
  @ApiProperty({ description: '房间ID', example: 1 })
  @PrimaryGeneratedColumn()
  roomID: number;

  @ApiProperty({ description: '房间类型', example: '标准间' })
  @Column()
  roomType: string;

  @ApiProperty({
    description: '房间价格',
    example: 299,
    minimum: 0,
  })
  @Column('float')
  price: number;

  @ApiProperty({
    description: '房间状态',
    example: '空闲',
    enum: ['空闲', '已预订', '已入住', '维修中'],
  })
  @Column()
  status: string;

  @ApiProperty({ description: '所属酒店', type: () => Hotel })
  @ManyToOne(() => Hotel, (hotel) => hotel.rooms)
  @JoinColumn({ name: 'hotelID' })
  hotel: Hotel;

  @ApiProperty({ description: '酒店ID', example: 1 })
  @Column()
  hotelID: number;

  @ApiProperty({ description: '房间的所有订单', type: () => [Order] })
  @OneToMany(() => Order, (order) => order.room)
  orders: Order[];
}
